import { CommonModule } from '@angular/common';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AdminAuthGuard } from './shared/guard/admin-auth.guard';

// primeng
import {ButtonModule} from 'primeng/button';
import {MultiSelectModule} from 'primeng/multiselect';
import { AgentAuthGuard } from './shared/guard/agent-auth.guard';
import { CustomerAuthGuard } from './shared/guard/customer-auth.guard';
import { NgProgressModule } from 'ngx-progressbar';

// AoT requires an exported function for factories
export const createTranslateLoader = (http: HttpClient) => {
     //for development
    // return new TranslateHttpLoader(
    //     http,
    //     '/start-angular/SB-Admin-BS4-Angular-6/master/dist/assets/i18n/',
    //     '.json'
    // ); 
    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
};

@NgModule({
    imports: [
        CommonModule,
        BrowserModule,
        BrowserAnimationsModule,
        HttpClientModule,
        NgProgressModule,
        // primeng
        ButtonModule,
        MultiSelectModule,

        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: createTranslateLoader,
                deps: [HttpClient]
            }
        }),


        AppRoutingModule
    ],
    declarations: [AppComponent,],
    providers: [AdminAuthGuard,AgentAuthGuard,CustomerAuthGuard],
    bootstrap: [AppComponent]
})
export class AppModule {}
